package com.idp.biz.bpwagecurve.service.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.common.model.PageModel;
import com.common.utils.ResourceUtil;
import com.idp.biz.bpwagecurve.service.BpWageCurveService;
import com.idp.biz.bpwagecurve.dao.BpWageCurveDao;
import com.idp.biz.bpwagecurve.entity.BpWageCurve;

/**
 * 用户薪酬曲线service实现类
 * 
 * @author Stone 2019-06-29
 *
 */
@Service("bpWageCurveService")
public class BpWageCurveServiceImpl implements BpWageCurveService {

	@Autowired
	private BpWageCurveDao bpWageCurveDao;
	
	@Override
	public PageModel<BpWageCurve> findByPage(BpWageCurve bpWageCurve, PageModel<BpWageCurve> page) {
		PageHelper.offsetPage(page.getStart(), page.getLength());
		page.initData(bpWageCurveDao.findByPage(bpWageCurve));
		return page;
	}
	
	@Override
	public List<BpWageCurve> findBySearch(BpWageCurve bpWageCurve) {
		return bpWageCurveDao.find(bpWageCurve);
	}
	
	@Override
	public BpWageCurve getById(String id) {
		return bpWageCurveDao.getById(id);
	}

	@Override
	public void add(BpWageCurve bpWageCurve) {
		bpWageCurve.setId(ResourceUtil.getUUID());
		bpWageCurveDao.add(bpWageCurve);
	}
	
	@Override
	public void update(BpWageCurve bpWageCurve) {
//		bpWageCurveDao.update(bpWageCurve);
		bpWageCurveDao.updateNotNull(bpWageCurve);
	}

	@Override
	public void delete(String ids) {
		List<String> idList = Arrays.asList(ids.split(","));
		bpWageCurveDao.batchDelete(idList);
	}
 	
}